﻿@model Models.Models.StoreList
@using WebApp.Classes

@{
    ViewBag.Title = "Store Management";

    var rights = new WebApp.Classes.UserRights("Store Management");
}

@Styles.Render("~/treeview/jquery.treeview.css")        
@Scripts.Render("~/treeview/jquery.treeview.js")

@Scripts.Render("~/scripts/app/" + Path.GetFileNameWithoutExtension(Server.MapPath(VirtualPath)) + ".js")

@Html.Hidden("routeId", ViewContext.RouteData.Values["id"] == null ? "xx" : ViewContext.RouteData.Values["id"])

    <fieldset>
        @Html.GetTitle("/Images/glyphicons/png/glyphicons_202_shopping_cart.png", new string[] { HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString() + "/" + ViewBag.Title })

        <div class="alert alert-info">
            Please select a store to update or add a new one.
            <div style='float: right' id="divRevoked">            
                Hide Revoked:
                <input type="checkbox" id="hideRevoked" style = "vertical-align: middle" @Html.Raw(ViewBag.hideRevoked == true ? "checked" : "") />
            </div>
        </div>
        
        <table width="100%">
            <tbody>
                <tr>
                    <td width="50%" valign="top">
                        <div style="overflow: auto; height: 500px; border-style: ridge; border-width: 1px; border-color: #DDDDDD">                            
                            @Html.TreeView(Model.Root).Children(m => m.Children(Model.List)).HtmlAttributes(new { id = "tree" }).ChildrenHtmlAttributes(new { @class = "subItem" }).ItemText(m => m.Name).ItemTemplate(@<text>@Ajax.ActionLink(@item.Name, "EditViewStore", new { id = @item.ID }, new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "divEditStore" })</text>)
                        </div>
                        
                        @if (rights.FullControl)
                        { 
                           
                        <div id="divTreeBtns" class="btn-group" style="display: none; margin-top: 10px" >
                            <button type="submit" class="btn btn-inverse" id="addStore"><i class="icon-plus-sign icon-white"></i> Add New</button>            
                        </div>
                        }
                    </td>
                    <td width="50%" valign="top">
                        <div id="divEditStore">
                            @{
                                Html.RenderAction("EditViewStore", "Store", new { id = ViewBag.storeId });
                            }
                        </div>                          
                    </td>
                </tr>
            </tbody>
        </table>

    </fieldset>


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
